package org.xdj.blue.java.netty.server;

import java.net.InetAddress;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class HelloHandle extends SimpleChannelInboundHandler<String> {

	@Override
	protected void channelRead0(ChannelHandlerContext ctx, String msg)
			throws Exception {
		System.out.println("----HelloHandle.channelRead0----");
		System.out.println("reqMsg："+msg);
		String resp = "received your msg!"+"\n";
		ctx.writeAndFlush(resp);
		System.out.println("server response over!");
	}
	@Override
	public void channelActive(ChannelHandlerContext ctx) throws Exception {
		System.out.println("----remoteAddress："+ctx.channel().remoteAddress()+"----");
		ctx.writeAndFlush("welcome to "+InetAddress.getLocalHost().getHostName()+ " services!"+"\n");
		super.channelActive(ctx);
	}
}
